package com.foogui.primary.sync;

public class Client {
    public static void main(String[] args) {
        //测试Lock线程通信
        Ticket ticket = new LockTicket();
        //synchronized线程通信
        //Ticket ticket = new SyncTicket();
        new Thread(()->{
            try {
                while (true){
                    ticket.removeTicket();

                }

            } catch (InterruptedException e) {
                throw new RuntimeException(e);
            }
        },"A").start();

        new Thread(()->{
            try {
                while (true){
                    ticket.removeTicket();

                }
            } catch (InterruptedException e) {
                throw new RuntimeException(e);
            }
        },"B").start();

        new Thread(()->{
            try {
                while (true){
                    ticket.addTicket();

                }
            } catch (InterruptedException e) {
                throw new RuntimeException(e);
            }
        },"C").start();
    }
}
